package com.yike.user.controller;

import com.yike.user.entity.ShopCamera;
import com.yike.user.param.BindingShopCameraParam;
import com.yike.user.service.ShopCameraService;
import lombok.extern.slf4j.Slf4j;
import com.yike.common.base.BaseController;
import com.yike.common.api.ApiResult;
import com.yike.common.log.Module;
import com.yike.common.log.OperationLog;
import com.yike.common.enums.OperationLogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 店铺摄像头表 控制器
 *
 * @author Sakura
 * @since 2024-09-12
 */
@Slf4j
@RestController
@RequestMapping("/shopCamera")
@Module("user")
@Api(value = "店铺摄像头API", tags = {"店铺摄像头管理"})
public class ShopCameraController extends BaseController {

    @Autowired
    private ShopCameraService shopCameraService;

    /**
     * 绑定
     */
    @PostMapping("/binding")
    @OperationLog(name = "绑定", type = OperationLogType.ADD)
    @ApiOperation(value = "绑定", response = ApiResult.class)
    public ApiResult<Boolean> binding(@RequestBody BindingShopCameraParam bindingShopCameraParam) throws Exception {
        boolean flag = shopCameraService.binding(bindingShopCameraParam);
        return ApiResult.result(flag);
    }

    /**
     * 解绑
     */
    @PostMapping("/unbind")
    @OperationLog(name = "解绑", type = OperationLogType.ADD)
    @ApiOperation(value = "解绑", response = ApiResult.class)
    public ApiResult<Boolean> unbind(@RequestBody BindingShopCameraParam bindingShopCameraParam) throws Exception {
        boolean flag = shopCameraService.unbind(bindingShopCameraParam);
        return ApiResult.result(flag);
    }

    /**
     * 店铺摄像头表分页列表
     */
    @PostMapping("/getShopCameraList/{shopNo}")
    //@OperationLog(name = "获取店铺摄像头列表", type = OperationLogType.PAGE)
    @ApiOperation(value = "获取店铺摄像头列表", response = ShopCamera.class)
    public ApiResult<List<String>> getShopCameraList(@PathVariable("shopNo") String shopNo) throws Exception {
        List<String> cameraNoList = shopCameraService.getShopCameraList(shopNo);
        return ApiResult.ok(cameraNoList);
    }

}

